package com.freemyleft.left.left_app.mian.index.work.waitingforclass.adapter;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.freemyleft.left.left_app.R;
import com.freemyleft.left.zapp.ui.recycler.MultipleItemEntity;
import com.freemyleft.left.zapp.ui.recycler.MultipleRecyclerAdapter;
import com.freemyleft.left.zapp.ui.recycler.MultipleViewHolder;

import java.util.List;

public class WaitingForClassAdapter extends MultipleRecyclerAdapter {

    public WaitingForClassAdapter(List<MultipleItemEntity> data) {
        super(data);
        addItemType(1, R.layout.item_waittingforclass);
    }

    @Override
    protected void convert(MultipleViewHolder holder, MultipleItemEntity entity) {
        super.convert(holder, entity);
        String date = entity.getField(WaitingForClassFiles.DATE);
        String student_message = entity.getField(WaitingForClassFiles.STUDENT_MESSAGE);
        String price = entity.getField(WaitingForClassFiles.PRICE);
        String location = entity.getField(WaitingForClassFiles.LOCATION);
        String type = entity.getField(WaitingForClassFiles.TYPE);
        String id = entity.getField(WaitingForClassFiles.ID);
        holder.setText(R.id.tv_date, date);
        holder.setText(R.id.tv_student_message, student_message);
        holder.setText(R.id.tv_price, "￥" + price + "/小时");
        holder.setText(R.id.tv_location, location);
        Glide.with(mContext).load(entity.getField(WaitingForClassFiles.HEAD)).into((ImageView) holder.getView(R.id.student_photo));
        holder.addOnClickListener(R.id.tv_yuxi);//预习
        holder.addOnClickListener(R.id.imag_communication);//沟通
        holder.addOnClickListener(R.id.wancheng);//完成
        //待上课
        if (type.equals("1")) {
            holder.setText(R.id.id, id);
            holder.setText(R.id.tv_date, date);
            holder.setText(R.id.tv_student_message, student_message);
            holder.setText(R.id.tv_price, "￥" + price + "/小时");
            holder.setText(R.id.tv_location, location);
            Glide.with(mContext).load(entity.getField(WaitingForClassFiles.HEAD)).into((ImageView) holder.getView(R.id.student_photo));
            holder.addOnClickListener(R.id.tv_yuxi);
            holder.addOnClickListener(R.id.imag_communication);
            ImageView wancheng = holder.getView(R.id.wancheng);
            holder.addOnClickListener(R.id.wancheng);
            ImageView yuxizuoye = holder.getView(R.id.tv_yuxi);
            yuxizuoye.setImageResource(R.mipmap.yuxizuoye);
            wancheng.setImageResource(R.mipmap.wancheng);
        } else if (type.equals("2")) {
            holder.setText(R.id.id, id);
            holder.setText(R.id.tv_date, date);
            holder.setText(R.id.tv_student_message, student_message);
            holder.setText(R.id.tv_price, "￥" + price + "/小时");
            holder.setText(R.id.tv_location, location);
            Glide.with(mContext).load(entity.getField(WaitingForClassFiles.HEAD)).into((ImageView) holder.getView(R.id.student_photo));
            holder.addOnClickListener(R.id.tv_yuxi);
            holder.addOnClickListener(R.id.imag_communication);
            ImageView wancheng = holder.getView(R.id.wancheng);
            holder.addOnClickListener(R.id.wancheng);
            wancheng.setImageResource(R.mipmap.qupingjia);
            ImageView yuxizuoye = holder.getView(R.id.tv_yuxi);
            yuxizuoye.setImageResource(R.mipmap.kehouzuoye);

        }

    }


}
